package vmcs.simulationsystem;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * Title:        VMCS
 * Description:
 * Copyright:    Copyright (c) 2001
 * Company:      ISS
 * @author Pang Pingli
 * @version 1.0
 */

import java.awt.*;

import vmcs.common.Constant;
import vmcs.controller.MaintenanceController;

public class PriceDisplayListener implements ActionListener {
  private MaintenanceController  mctrl;

  public PriceDisplayListener(MaintenanceController  mc) {
    mctrl = mc;
  }
  public void actionPerformed(ActionEvent e) {
    /**@todo: Implement this java.awt.event.ActionListener method*/
    TextField  txt;

    String       sp;
    int          ip;
    try {
      txt = (TextField) e.getSource();
      sp = txt.getText();

      ip = Integer.parseInt(sp);
    } catch (NumberFormatException ee){
    	if(mctrl.getMaintenancePanel() != null && mctrl.getMaintenancePanel() instanceof Dialog){
    		Dialog dia = (Dialog)mctrl.getMaintenancePanel();
    		MessageDialog ms = new MessageDialog(dia, Constant.NUMBER_FORMAT_ERROR);		
    	}
      return;
    }
    mctrl.setPrice(ip);
  }
}